package com.charmzenus.champion.base;


import com.charmzenus.champion.base.db.DBHelper;
import com.charmzenus.champion.base.net.Constant;
import com.charmzenus.champion.base.net.ErrorInfo;
import com.charmzenus.champion.base.net.ResponseInfo;
import com.charmzenus.champion.base.net.ResponseInfoAPI;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * 业务层公共部分代码封装
 */

public abstract class BasePresenter {

    protected static ResponseInfoAPI responseInfoAPI;
    // 数据库
    // 网络
    protected DBHelper helper;

    public BasePresenter() {

/*        Retrofit.Builder builder = new Retrofit.Builder();
        builder.baseUrl(Constant.BASE_URL);
        builder.addConverterFactory(GsonConverterFactory.create());// Gson解析

        Retrofit retrofit = builder.build();*/

        // 第一次初始化完成后，所有子类都可以使用
        if (responseInfoAPI == null) {
            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(Constant.BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();

            responseInfoAPI = retrofit.create(ResponseInfoAPI.class);
        }
        helper = DBHelper.getInstance();
    }

}
